-- Compile freshly lua files.
if file.exists("compile.lc") then
  dofile("compile.lc")
else
  dofile("compile.lua")
end

-- Set up NodeMCU's WiFi
dofile('wifi.lc')(function(mode, ip)
  -- on get ip
  if mode ~= wifi.STATION then
    -- Start nodemcu-sertver
    local conf = dofile('conf/server.lc')
    if (dofile("server/server.lc")(conf.port)) then
      print("nodemcu-server running at:")
      print("   http://" .. ip .. ":" ..  conf.port)
    end
    conf = nil
    collectgarbage()
  else
  end
end)

collectgarbage()